<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>

<html>
  <head>
  	<title>注册</title>
  	<style type="text/css">
  		.divmain{
  			margin-top: 15%;
			margin-bottom: 15%;
  		}
  		input {
      		accent-color: red;
    	}
  	</style>
  	<script type="text/javascript">
  	
  		function check(){
  			 var username = document.getElementsByName("username")[0].value;
  			 var password = document.getElementsByName("password")[0].value;
  			 var repassword = document.getElementsByName("repassword")[0].value;
  			 var mail = document.getElementsByName("mail")[0].value;
 			 var password_reg=/^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])[a-zA-Z0-9]{6,10}$/;//  验证密码格式的正则表达式
  			 var mail_reg =/^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$/;//  验证邮箱格式的正则表达式
  			 if(username=="" || password=="" || repassword==""){
  			 	alert("用户名或密码不能为空");
  			 }else if(password_reg.test(password)==false){
  			 	alert("密码长度6-10位，由数字（0-9）、大写字母（A-Z）、小写字母（a-z）共同组成，缺一不可！");
  			 }else if(password!=repassword){
  			 	alert("两次输入密码不一致");
  			 }else if(mail!="" && mail_reg.test(mail)==false ){
  			 	alert("邮箱格式错误");
  			 }else{
  			 	document.getElementById("RegisterForm").submit();
  			 }
	
  			
  		}
  	</script>
  <body background="${pageContext.request.contextPath}/image/register.png"style=" background-repeat:no-repeat ;background-size:100% 100%;
		background-attachment: fixed;">
	<div align="center" class="divmain" >
	<h2><font color="white">用户注册</font></h2>
    <form id="RegisterForm" action="servlet/RegisterServlet" method="post" style="color: white">
    	<table style=" color: white;">
    		<tr height="50">
    			<td>用&nbsp;&nbsp;户&nbsp;&nbsp;名：</td>
    			<td><input type="text" name="username"   onblur="Name()"></td>
    		</tr>
    		<tr height="50">
    			<td>密&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;码：</td>
    			<td><input type="password" name="password"></td>
    		</tr>
    		<tr height="50">
    			<td>确认密码：</td>
    			<td><input type="password" name="repassword"  ></td>
    		</tr>
    		<tr height="50">
    			<td>性&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;别：</td>
    			<td>
    			<input type="radio" name="usex" value="男" checked="checked">男
    			<input type="radio" name="usex" value="女">女
    			</td>
    		</tr>
    		<tr height="50">
    			<td>邮&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;箱：</td>
    			<td><input type="email" name="mail"></td>
    		</tr>
    		<tr  height="50">
    			<td align="center" colspan="2"><input type="button"  value="注册" onclick="check()" ></td>
    		</tr>
    	</table>
    </form>
    </div>
  </body>
</html>
    	